﻿using System;
using System.Collections.Generic;
using GeoAPI.Geometries;
using NetTopologySuite.Algorithm;

namespace NetTopologySuite.Noding
{
	[Obsolete("see InteriorIntersectionFinderAdder")]
	public class IntersectionFinderAdder : ISegmentIntersector
	{
		public IntersectionFinderAdder(LineIntersector li)
		{
			this._li = li;
			this._interiorIntersections = new List<Coordinate>();
		}

		public IList<Coordinate> InteriorIntersections
		{
			get
			{
				return this._interiorIntersections;
			}
		}

		public void ProcessIntersections(ISegmentString e0, int segIndex0, ISegmentString e1, int segIndex1)
		{
			if (e0 == e1 && segIndex0 == segIndex1)
			{
				return;
			}
			Coordinate[] coordinates = e0.Coordinates;
			Coordinate p = coordinates[segIndex0];
			Coordinate p2 = coordinates[segIndex0 + 1];
			Coordinate[] coordinates2 = e1.Coordinates;
			Coordinate p3 = coordinates2[segIndex1];
			Coordinate p4 = coordinates2[segIndex1 + 1];
			this._li.ComputeIntersection(p, p2, p3, p4);
			if (!this._li.HasIntersection)
			{
				return;
			}
			if (!this._li.IsInteriorIntersection())
			{
				return;
			}
			for (int i = 0; i < this._li.IntersectionNum; i++)
			{
				this._interiorIntersections.Add(this._li.GetIntersection(i));
			}
			((NodedSegmentString)e0).AddIntersections(this._li, segIndex0, 0);
			((NodedSegmentString)e1).AddIntersections(this._li, segIndex1, 1);
		}

		public bool IsDone
		{
			get
			{
				return false;
			}
		}

		private readonly LineIntersector _li;

		private readonly IList<Coordinate> _interiorIntersections;
	}
}
